/*
 * @Author: 李明明
 * @Date: 2021-08-19 14:21:11
 * @LastEditTime: 2021-08-19 17:15:21
 * @LastEditors:
 * @Description:
 * @FilePath: /face/src/utils/jiami.js
 * 代码版权方：'政府采购信息网'
 */

// Vue.prototype.AES_jiami = function(word, key) {
//   let keyTemp = this.cryptoJs.enc.Utf8.parse(key);
//   let wordTemp = this.cryptoJs.enc.Utf8.parse(word);
//   let enc = this.cryptoJs.AES.encrypt(wordTemp, keyTemp, {
//     mode: this.cryptoJs.mode.ECB,
//     padding: this.cryptoJs.pad.Pkcs7
//   });
//   return enc.toString();
// };
// Vue.prototype.MD5_jiami = function(word) {
//   return this.cryptoJs.MD5(word).toString();
// };

import Vue from "vue";

export default {
  AES_jiami(word, key) {
    // 只能在客户端运行该方法
    if (process.client) {
      let keyTemp = Vue.prototype.cryptoJs.enc.Utf8.parse(key);
      let wordTemp = Vue.prototype.cryptoJs.enc.Utf8.parse(word);
      let enc = Vue.prototype.cryptoJs.AES.encrypt(wordTemp, keyTemp, {
        mode: Vue.prototype.cryptoJs.mode.ECB,
        padding: Vue.prototype.cryptoJs.pad.Pkcs7
      });
      return enc.toString();
    }
  },
  MD5_jiami(word) {
    if (process.client) {
      return Vue.prototype.cryptoJs.MD5(word).toString();
    }
  }
};
